#include"Sort.h"
void Swap(int* x, int* y)
{
	int tmp = *x;
	*x = *y;
	*y = tmp;
}
void Print(int* arr, int n)
{
	for (int i = 0; i < n; i++)
	{
		printf("%d ", arr[i]);
	}
	printf("\n");
}
void InsertSort(int* arr, int n)
{
	int begin, tmp;
	for (int i = 0; i < n - 1; i++)
	{
		begin = i;
		tmp = arr[begin + 1];
		while (begin >= 0)
		{
			if (arr[begin] > tmp)
			{
			arr[begin+1]=arr[begin];
				begin--;
			}
			else {
				break;
			}
		}
		arr[begin + 1] = tmp;
	}
}
void ShellSort(int* arr, int n)
{
	int begin, tmp;
	int gap=n;
	while (gap > 1)
	{
		gap = gap / 3 + 1;
		for (int i = 0; i < n- gap; i++)
		{
			begin = i;
			tmp = arr[begin + gap];
			while (begin >= 0)
			{
				if (arr[begin] > tmp)
				{
					arr[begin + gap] = arr[begin];
					begin -= gap;

				}
				else {
					break;
				}
			}
			arr[begin + gap] = tmp;
		}
	}
}